import { createAxios } from '@/utils/createRequest'
import api from '@/api/apiUrl'

const axios = createAxios({
  baseURL: process.env.VUE_APP_API_NOTICE_URL,
  tokenField: 'Authorization'
})

export function GetPostList (parameter) {
  return axios({
    url: api.Notice.list,
    method: 'get',
    params: parameter
  })
}

export function GetReleasedList (parameter) {
  return axios({
    url: api.Notice.releasedList,
    method: 'get',
    params: parameter
  })
}

export function SavePost (parameter) {
  return axios({
    url: parameter.id ? `${api.Notice.notice}/${parameter.id}` : api.Notice.notice,
    method: parameter.id ? 'put' : 'post',
    data: parameter
  })
}

export function DeletePost (parameter) {
  return axios({
    url: `${api.Notice.notice}/${parameter.id}`,
    method: 'delete',
    data: parameter
  })
}

export function UpdateRead (parameter) {
  return axios({
    url: api.Notice.updateRead,
    method: 'post',
    data: parameter
  })
}

export function UpdateUnRead (parameter) {
  return axios({
    url: api.Notice.updateUnRead,
    method: 'post',
    data: parameter
  })
}
